#include "Color.h"
/**
 *      Color的运算
 */
ColorType operator|(const ColorType & c1, const ColorType & c2){
    return (ColorType)(c1|c2);
}
ColorType& operator|=(ColorType & c1, const ColorType & c2){
    c1 = c1 | c2;
    return c1;
}
/**
 *      ColorDefine颜色货物定义的实现
*/
ColorDefine::ColorDefine(ColorType color) : color(color) {
    this->serialization();
}
ColorDefine::ColorDefine(const std::initializer_list<ColorType> &t_arr):
    ColorDefine(ColorType::Color_NONE)
{
    for(auto it:t_arr){
        this->color |= it;
    }this->serialization();
}

std::string ColorDefine::serialization()
{
    if (hash_id.size())
        return hash_id;
    else
        return hash_id = (char)color;
}

void ColorDefine::deserialization()
{
    if (hash_id.size() != 1)
    {
        std::cerr<<("color's hash_id's length should be one!");
    }
    color = (ColorType)hash_id[0];
}
void ColorDefine::clear() { return; }
bool ColorDefine::isNone() { return color == ColorType::Color_NONE; }
void turnDirection(bool is_clockwise){}

ColorDefine::~ColorDefine(){}
/**
 *      ColorCargo颜色货物的实现
*/
ColorCargo::ColorCargo(ColorDefine *define) : Cargo(define) {}
